<template>
  <div>
    <div class="header">
      <div class="box">
        <van-icon name="apps-o" size="24px" color="#fff" />
        <div class="input">
          <van-icon name="search" size="20px"/>
          <input type="text" placeholder="满66包邮，输入名称查询" @focus="search">
        </div>
        <van-icon name="shopping-cart-o" size="24px" color="#fff" />
      </div>
    </div>
    <div class="section">
      <Banner/>
      <Tvb/>
      <div class="box">
        <div class="img1">
          <img src="../assets/images/home/01.jpg" alt="">
          <div class="box-img">
            <div class="left">
              <img src="../assets/images/home/02.png" alt="">
            </div>
            <div class="right">
              <img src="../assets/images/home/03.png" alt="">
              <img src="../assets/images/home/04.png" alt="">
            </div>
          </div>
        </div>
      </div>
      <div class="box">
        <div class="img1">
          <img src="../assets/images/home/05.jpg" alt="">
          <div class="box-img1">
              <img src="../assets/images/home/06.jpg" alt="">
              <img src="../assets/images/home/07.jpg" alt="">
          </div>
        </div>
      </div>
      <div class="box1">
        <div class="img">
          <div class="top">
            <img src="../assets/images/home/08.png" alt="">
            <img src="../assets/images/home/09.jpg" alt="">
            <img src="../assets/images/home/10.jpg" alt="">
          </div>
          <div class="bottom">
            <img src="../assets/images/home/11.jpg" alt="">
            <img src="../assets/images/home/12.jpg" alt="">
            <img src="../assets/images/home/13.jpg" alt="">
            <img src="../assets/images/home/14.jpg" alt="">
          </div>
        </div>
      </div>
      <!-- 通知栏 -->
      <div class="notice">
        <div class="noticebar">
          <img src="../assets/images/home/notice.png" alt="">
          <van-notice-bar color="#666666" background="#ffffff" :scrollable="false">
            <van-swipe
              vertical
              class="notice-swipe"
              :autoplay="2000"
              :show-indicators="false"
            >
              <van-swipe-item v-for="(item,index) in notice" :key="index">{{item.archives_name}}</van-swipe-item>
            </van-swipe>
          </van-notice-bar>
        </div>
      </div>
      <!-- tab选项卡 -->
      <div class="tab">
        <div 
          class="title" 
          v-for="(item,index) in tab" 
          :key="index"
          @click="handleJump(index)"
        >
          <h2 
            :class="index==status?'active':''" 
            style="font-size:20px;"
            >{{item.title}}</h2>
          <p 
            :class="index==status?'active':''"  
            style="font-size:12px;"
          >{{item.sub_title}}</p>
        </div>
      </div>
      <!-- <Homelist/> -->
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
import Banner from '../components/Banner.vue'
import Tvb from '../components/Tvb.vue'
// import Homelist from './Homelist.vue'
import {homelist} from '../api/home'
export default {
    components: {
      Banner,
      Tvb,
    },
    data() {
      return {
        notice: [],
        tab:[
          {title:"全部",sub_title:"猜你喜欢"},
          {title:"销量",sub_title:"热卖好货"},
          {title:"实惠",sub_title:"高性价比"},
        ],
        status:0
      }
    },
    created () {
      homelist().then(res=>{
        // console.log(res.data.data.moduleMap[9].item_data);
        this.notice = res.data.data.moduleMap[9].item_data
      })
    },
    methods: {
      handleJump(idx) {
        this.status = idx
        // console.log(idx);
        if(idx===0){
          this.$router.push('/')
        }else if(idx===1){
          this.$router.push('/tab2')
        }else{
          this.$router.push('/tab3')
        }
      },
      search(){
        // console.log(111);
        this.$router.push('/search')
      }
    },
}
</script>
<style src="../assets/css/home.css" scoped></style>
<style scoped>
.notice-swipe {
    height: 40px;
    line-height: 40px;
  }
</style>
